/**
 * Always hostile enemy that attacks in melee
 */

import { mergeTemplates } from '$lib/builder';
import { Clock } from '$lib/clock';
import { AI, Description, Glyph } from '$lib/components';
import { Heart } from '$lib/content/heart';
import { defineComponent } from '$lib/ecs';
import { Eyes } from '$lib/eyes';
import { registerAI } from '$lib/simulate';
import { Attackable } from './attack';
import { humanTemplate } from './human';

export const Thug = defineComponent('Thug', {});

export const thugTemplate = mergeTemplates(humanTemplate, [
  [AI],
  [Thug],
  [Description, {
    summary: "Thug",
    description: "An aggresively looking human being. Reasoning with them seems futile.",
  }],
  [Eyes, {
    range: 5,
  }],
  [Glyph, {
    color: '#b24',
  }],
  [Attackable], // TODO: move this to human template when hostility switch implemented
]);

registerAI({
  target: Thug,
  action: (world, e) => {
    const delay = Heart.heartbeat[e];
    Clock.time[e] += delay;
  },
});
